package com.ysy.tz.core.excel;

import com.github.pagehelper.PageInfo;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import org.apache.commons.collections4.CollectionUtils;

public class ExcelData {
    private List<TableColumn> tableColumns;
    private PageInfo datas;
    private List<List<String>> headers;

    public ExcelData(List<TableColumn> tableColumns, PageInfo datas) {
        this.tableColumns = tableColumns;
        this.datas = datas;
    }

    public List<List<String>> getHeaders() {
        if (this.headers == null) {
            this.headers = (List)this.tableColumns.stream().map((tableColumn) -> {
                String text = tableColumn.getText();
                ArrayList<String> idList = new ArrayList(1);
                idList.add(text);
                return idList;
            }).collect(Collectors.toList());
        }

        return this.headers;
    }

    public long getTotal() {
        return this.datas.getTotal();
    }

    public List<List<Object>> getDatas() {
        List dataList = this.datas.getList();
        if (!CollectionUtils.isNotEmpty(dataList)) {
            return null;
        } else {
            List<List<Object>> result = new ArrayList();
            Iterator var3 = dataList.iterator();

            while(var3.hasNext()) {
                Object o = var3.next();
                List<Object> row = new ArrayList();
                Iterator var6 = this.tableColumns.iterator();

                while(var6.hasNext()) {
                    TableColumn tableColumn = (TableColumn)var6.next();
                    TableColumn.CellDataFeatures cdf = new TableColumn.CellDataFeatures((TableView)null, tableColumn, o);
                    ObservableValue observableValue = (ObservableValue)tableColumn.getCellValueFactory().call(cdf);
                    if (observableValue == null) {
                        row.add("");
                    } else {
                        row.add(observableValue.getValue());
                    }
                }

                result.add(row);
            }

            return result;
        }
    }

    public List<TableColumn> getTableColumns() {
        return this.tableColumns;
    }

    public void setTableColumns(List<TableColumn> tableColumns) {
        this.tableColumns = tableColumns;
    }

    public void setDatas(PageInfo datas) {
        this.datas = datas;
    }

    public void setHeaders(List<List<String>> headers) {
        this.headers = headers;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ExcelData)) {
            return false;
        } else {
            ExcelData other = (ExcelData)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label47: {
                    Object this$tableColumns = this.getTableColumns();
                    Object other$tableColumns = other.getTableColumns();
                    if (this$tableColumns == null) {
                        if (other$tableColumns == null) {
                            break label47;
                        }
                    } else if (this$tableColumns.equals(other$tableColumns)) {
                        break label47;
                    }

                    return false;
                }

                Object this$datas = this.getDatas();
                Object other$datas = other.getDatas();
                if (this$datas == null) {
                    if (other$datas != null) {
                        return false;
                    }
                } else if (!this$datas.equals(other$datas)) {
                    return false;
                }

                Object this$headers = this.getHeaders();
                Object other$headers = other.getHeaders();
                if (this$headers == null) {
                    if (other$headers != null) {
                        return false;
                    }
                } else if (!this$headers.equals(other$headers)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ExcelData;
    }

    public int hashCode() {
        int result = 1;
        Object $tableColumns = this.getTableColumns();
        result = result * 59 + ($tableColumns == null ? 43 : $tableColumns.hashCode());
        Object $datas = this.getDatas();
        result = result * 59 + ($datas == null ? 43 : $datas.hashCode());
        Object $headers = this.getHeaders();
        result = result * 59 + ($headers == null ? 43 : $headers.hashCode());
        return result;
    }

    public String toString() {
        return "ExcelData(tableColumns=" + this.getTableColumns() + ", datas=" + this.getDatas() + ", headers=" + this.getHeaders() + ")";
    }
}
